1. Field of the Invention
The present invention relates to an electronic apparatus, a control method thereof, a host device, and a control method thereof.
2. Description of the Related Art
In recent years, IC (Integrated Circuit) cards (included in an electronic apparatus) having a non-volatile memory and another function have been developed and spread on the market. For example, a technique such that an IC card having a flash memory and a wireless communication function is attached to PDA (Personal Digital Assistants: host device), the IC card receives video data and audio data and transmits them to the PDA, and the PDA outputs the video data and the audio data from a display and a speaker thereof is being realized.
Conventionally, a function that a host device such as PDA transmits data to an IC card and the data are stored in a flash memory of the IC card is put to practical use.
In general, data transmission between a host device and an IC card is executed by means of a master/slave communication system in which the host device is a master. The host device transmits a command to the IC card, and accordingly the IC card returns a response to the host device. There are a host device and an IC card which can further transmit data as required after transmitting and receiving the command and the response respectively. The host device determines timing of the data transmission and a size of data, and accordingly the IC card receives or transmits the data.
One of the data transmissions between a host device and an IC card is a method called a multi-block transmission. The multi-block transmission is a method of, when data is a predetermined length or more (typically, a length of not less than a predetermined block size), (1) dividing the data into a plurality of data blocks with the predetermined block size and (2) intermittently transmitting the data blocks.
The host device determines a block size of one data block and transmits information about the block size to the IC card before transmitting the data. Concretely, the host device transmits a command (called as “the first block size setting command”) including block size setting data of 1 byte to the IC card, and the IC card sets received block setting size data in a register of the IC card.
Generally, the host device reads a capacity of a data buffer for transmission and reception in the IC card from the IC card, and sets the block size to a size not more than the capacity.
However, general-purpose IC cards can be attached to various host devices. The host devices can be mounted with various IC cards (all the IC cards conform to the same standard). For this reason, some host devices occasionally may not read a capacity of a data buffer in an IC card or improperly read it and set a block size which is larger than the capacity of the data buffer in the IC card.
In case that a data block having larger size than the capacity of the data buffer is transmitted from the host device to the IC card, the data buffer of the IC card overflows. Further, in case that the host device requests the IC card to transmit the data block having larger size than the capacity of the data buffer, the IC card can not transmit the data block. For this reason, when the IC card receives the command of setting the block size larger than the capacity of the data buffer, the IC card should transmit error information to the host device.
When the host device receives the error information as a response to the command of setting the block size, it should newly transmit a command of setting a block size not more than the capacity of the data buffer.
The IC card receives the first block size setting command including the block size setting data. When the block size setting data are larger than a buffer capacity, the IC card transmits the response which corresponds to the first block size setting command and includes error information to the host device. As a result, the data buffer of the IC card is prevented from overflowing at the time of the transmission/reception of the block size in advance.
The case of transmitting data from the host device to the IC card (transmitting a data writing command from the host device to the IC card) is explained. Firstly, the host device divides data to be transmitted according to a predetermined block size so as to create a plurality of data blocks. Then, the host device sequentially transmits the plural data blocks to the IC card.
The case of transmitting data from the IC card to the host device (transmitting a data reading command from the host device to the IC card) is explained. Firstly, the IC card divides data to be transmitted according to a block size set by the host device so as to create a plurality of data blocks. Then, the IC card sequentially transmits the plural data blocks to the host device.
Since the plural data blocks are intermittently transmitted, the multi-block transmission is effective for transmitting a large amount of data at a high speed.
Japanese Patent Application Laid-Open No. 11-298450 discloses an IC card of a conventional example that transmits an error signal to a host device when an overflow occurs at the time of serial data transmission. The conventional IC card transmits the error signal to the host device without via a built-in CPU. The conventional IC card transmits error information to the host device when a built-in receiving data buffer overflows.
Patent Document 1: Japanese Patent Application Laid-Open No. 11-298450